
/*
 * CorsoBridge.java
 *
 * Created on 06. Juni 2007, 07:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package sbc;

import org.xvsm.api.core.*;
import org.xvsm.client.ClientCapi;
import org.xvsm.api.core.notification.*;
import java.util.*;
import sbc.corso.util.*;
import sbc.factory.SensorFeature;
import sbc.corso.*;
import sbc.fact.*;
import sbc.factory.*;
import sbc.util.*;
import corso.lang.*;
import org.apache.log4j.*;
import sbc.util.Bridge;
import sbc.util.BridgeException;


/**
 *
 * @author mustermark
 */
public class MozartBridge implements Bridge<Unit> {
    
    private Capi capi;
    private List<CorsoVarOid> clientOids = new ArrayList<CorsoVarOid>();
    
    public MozartBridge(Capi c) {
        super();
        capi = c;
    }
    public void route(Unit u) throws BridgeException {
        sbc.xvsm.Unit tupleUnit = new sbc.xvsm.Unit(u.getBoard().getUID(), u.getSensorOne().getUID(), u.getSensorTwo().getUID());
        try {
            final ContainerRef cref = Util.getOrCreateNamedContainer(capi, sbc.xvsm.Defaults.CONTAINER.toString(), CoordinationTypes.FIFO);
            capi.write(cref, Arrays.asList(new Entry[]{tupleUnit.asTuple()}));
        } catch(Exception e) {
            System.out.println("Error routing to MotartSpace...");
            e.printStackTrace();
        }
        
        
    }
    
    
}
